<template>
  <div class="app-container">
    <!-- 查询搜索 -->
    <div class="filter-container">
      <el-input  v-model="listQuery.Code" placeholder="查询内容" style="width: 200px;" class="filter-item"  @keyup.enter.native="handleFilter" />
      <el-button v-waves  class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter" >
        查询
      </el-button>
    </div>
    <el-table :data="list"  border  style="width: 100%">
      <el-table-column  prop="Worker.Code" label="门店代码">  </el-table-column>
      <el-table-column  prop="Md.MdName" label="门店名称">  </el-table-column>
      <el-table-column  prop="Worker.Role" label="级别">  </el-table-column>
      <el-table-column  prop="Worker.Roles" label="类型">  </el-table-column>
      <el-table-column  prop="Worker.CreatedAt" label="注册时间">  </el-table-column>
      <el-table-column  prop="Worker.Name" label="注册名称">  </el-table-column>
      <el-table-column  prop="Worker.Phone" label="注册电话">  </el-table-column>
      <el-table-column  prop="Worker.Verify" label="审核状态">
        <template slot-scope="scope">
          <el-tag size="medium">{{ scope.row.Worker.Verify === 0 ? '未审核': '已审核' }}</el-tag>
      </template>
      </el-table-column>
      <el-table-column label="操作"  width="100">
        <template slot-scope="scope">
          <el-button :disabled ="scope.row.Worker.Verify !== 0" @click="handleAdminAudit(scope.row)" type="primary" >审核</el-button>
        </template>
      </el-table-column>
   </el-table>

    <!-- 分页 -->
    <pagination v-show="total > 0" :total="total"  :page.sync="listQuery.page"  :limit.sync="listQuery.limit"  @pagination="getMdAdminList" />

  </div>
</template>

<script>
import {mdAdminList, mdAdminAudit } from '@/api/mdlist'
import waves from '@/directive/waves' // waves directive
import { parseTime } from '@/utils'
import Pagination from '@/components/Pagination' // secondary package based on el-pagination

export default {
  name: 'cbd-mdadminlist',
  components: { Pagination },
  directives: { waves },
  data() {
    return {
      list: [],
      total: 0,
     
      listQuery: {
        my: '1',
        page: 1,
        limit: 10,
        importance: undefined,
        title: undefined,
        type: undefined,
      },
    
    }
  },
  created() {
    this.getMdAdminList()
  },
  methods: {
    getMdAdminList() {
      this.listLoading = true
      mdAdminList().then((res) => {
        if (res.msg === 'success') {
          console.log(res.list)
          res.list.forEach(v => {
            v.Worker.CreatedAt = parseTime(v.Worker.CreatedAt)
          });
          this.list = res.list
        }
      })
       
    },
    handleFilter() {
      this.listQuery.page = 1
      
    },  
    handleAdminAudit(row){
      let id = row.Worker.Id
      mdAdminAudit({Id:id}).then((res)=> {
        if (res.msg === 'success') {
          this.$message.success("操作成功");
           this.getMdAdminList()
        }else{
              this.$message.error(res.msg);
        }
      })
    }
  },
}
</script>
<style scoped>
.brand-list {
  width: 100%;
  padding: 20px 10px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}
.brand {
  width: 100px;
  height: 36px;
  text-align: center;
  line-height: 36px;
  margin: 0 10px 10px 0;
}
.brand button {
  width: 100px;
  height: 36px;
  font-size: 14px;
  color: #000;
  text-align: center;
  border-radius: 2px;
}
.active {
  background-color: #e46715;
  border: 1px solid #e46715;
}
.brand-btn {
  background: #f4f4f5;
  border: 1px solid #b9b8b8;
}
</style>
>
